import { request } from '@umijs/max';
import type { SortOrder } from 'antd/es/table/interface';

export interface UserItem {
  id: number;
  username: string;
  password: string;
  nickname: string;
  phone: string;
  email: string;
  role: string;
  status: string;
  createTime: string;
  lastLoginTime: string;
}

export async function UserList(params: {
  current?: number;
  pageSize?: number;
  sortField?: string;
  sortOrder?: SortOrder;
}) {
  return request('/api/user', {
    method: 'GET',
    params,
  });
}

export async function addUser(data: Omit<UserItem, 'id'>) {
  return request('/api/user/add', {
    method: 'POST',
    data,
  });
}

export async function updateUser(data: UserItem) {
  return request('/api/user/update', {
    method: 'POST',
    data,
  });
}

export async function deleteUser(id: number) {
  return request('/api/user/delete', {
    method: 'POST',
    data: { id },
  });
} 